package thread;

/**
 * rose说五次台词，死了，jack一直说，不死
 */
public class DeamonThreadDemo {
    public static void main(String[] args) {
        Thread rose = new Thread() { //创建rose线程
            public void run() {
                for (int i = 0; i < 5; i++) {
                    System.out.println("rose:let me go !"); //说五次台词
                    try {
                        Thread.sleep(1000);  //每一次间隔1秒
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.println("rose:啊啊啊啊啊啊啊AAAAAAaaaaaa...."); //说完后死了
                System.out.println("扑通");
            }
        };
        /**
         * 创建jack线程，一直说台词，每次间隔一秒
         */
        Thread jack  = new Thread(){
            public void run(){
                while (true){
                    System.out.println("jack:you jump!i jump!");
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        rose.start();
//        jack.setDaemon(true);
        jack.start();


    }
}
